package com.admission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.admission.dao.GroupRegisterDao;
import com.admission.model.GroupRegister;

@Repository
@Transactional
public class GroupRegisterManager {

	private GroupRegisterDao groupRegisterDao;

	@Autowired
	public void setGroupRegisterDao(GroupRegisterDao groupRegisterDao) {
		this.groupRegisterDao = groupRegisterDao;
	}
	
	/**
	 * 通过id找唯一对象，无返回null
	 * @param id
	 * @return
	 */
	public GroupRegister getGroupRegisterById(String id) {
  		return groupRegisterDao.findUniqueBy("id", id);
  	}
	
	/**
	 * 通过手机号找唯一对象，无返回null
	 * @param mobile
	 * @return
	 */
	public GroupRegister getGroupRegisterByPhone(String mobile) {
  		return groupRegisterDao.findUniqueBy("mobile", mobile);
  	}
	
	/**
	 * 保存
	 * @param entity
	 * @throws Exception
	 */
	public void save(GroupRegister entity) throws Exception{
		groupRegisterDao.save(entity);
	}
	
	/**
	 * 通过filter分页查询
	 * @param page
	 * @param filters
	 * @return
	 */
	public Page<GroupRegister> getPageByFilter(Page<GroupRegister> page,
			List<PropertyFilter> filters) {
		return groupRegisterDao.findPage(page, filters);
	}
}
